package com.wutuo.wtservice.provider.dao;


import com.wutuo.wtservice.provider.domain.WtType;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

/**
 * @author lvh
 * @version 1.0
 */
public class BaseWtTypeSqlProvider implements java.io.Serializable {

    public String insertSelective(WtType record) {
        BEGIN();
        INSERT_INTO("wt_type");
        insertKey(record);
        return SQL();
    }

    public void insertKey(WtType record) {

        if (record.getName() != null) {
            VALUES("name", "#{name,jdbcType=VARCHAR}");
        }
        if (record.getTypeDescribe() != null) {
            VALUES("type_describe", "#{typeDescribe,jdbcType=VARCHAR}");
        }
        if (record.getCreateBy() != null) {
            VALUES("create_by", "#{createBy,jdbcType=BIGINT}");
        }
        if (record.getCreateDate() != null) {
            VALUES("create_date", "#{createDate,jdbcType=DATE}");
        }
        if (record.getUpdateBy() != null) {
            VALUES("update_by", "#{updateBy,jdbcType=BIGINT}");
        }
        if (record.getUpdateDate() != null) {
            VALUES("update_date", "#{updateDate,jdbcType=DATE}");
        }
        if (record.getRemarks() != null) {
            VALUES("remarks", "#{remarks,jdbcType=VARCHAR}");
        }
        if (record.getDelFlag() != null) {
            VALUES("del_flag", "#{delFlag,jdbcType=VARCHAR}");
        }
    }

    public String updateByPrimaryKeySelective(WtType record) {
        BEGIN();
        UPDATE("wt_type");
        updateKey(record);
        WHERE("id = #{id,jdbcType=BIGINT}");
        return SQL();
    }

    public void updateKey(WtType record) {
        if (record.getId() != null) {
            SET("id = #{id,jdbcType=BIGINT}");
        }
        if (record.getName() != null) {
            SET("name = #{name,jdbcType=VARCHAR}");
        }
        if (record.getTypeDescribe() != null) {
            SET("type_describe = #{typeDescribe,jdbcType=VARCHAR}");
        }
        if (record.getCreateBy() != null) {
            SET("create_by = #{createBy,jdbcType=BIGINT}");
        }
        if (record.getCreateDate() != null) {
            SET("create_date = #{createDate,jdbcType=DATE}");
        }
        if (record.getUpdateBy() != null) {
            SET("update_by = #{updateBy,jdbcType=BIGINT}");
        }
        if (record.getUpdateDate() != null) {
            SET("update_date = #{updateDate,jdbcType=DATE}");
        }
        if (record.getRemarks() != null) {
            SET("remarks = #{remarks,jdbcType=VARCHAR}");
        }
        if (record.getDelFlag() != null) {
            SET("del_flag = #{delFlag,jdbcType=VARCHAR}");
        }
    }
}